/**
 * Copyright (c) 2016-2019 九点科技 All rights reserved.
 *
 * http://www.9dyun.cn
 *
 * 版权所有，侵权必究！
 */
package com.dian.modules.sale.controller;

import java.util.List;
import java.util.Map;

import com.dian.common.annotation.SysLog;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.dian.common.controller.AbstractController;
import com.dian.modules.sale.entity.DeliverHeadEntity;
import com.dian.modules.sale.service.DeliverHeadService;
import com.dian.modules.sale.vo.DeliverHeadExportVO;
import com.dian.common.utils.PageUtils;
import com.dian.common.utils.R;

/**
 * 销售发货单
 *
 * @author xiaolai
 * @email xiaolai@9dyun.cn
 * @date 2019-06-21 16:00:09
 */
@RestController
@Api("销售发货单接口")
@RequestMapping("sale/deliverHead")
public class DeliverHeadController extends AbstractController{
    @Autowired
    private DeliverHeadService deliverHeadService;

    /**
     * 销售发货单列表
     */
    @SysLog("销售发货单列表")
    @GetMapping("/list")
    @ApiOperation("销售发货单列表")
    @RequiresPermissions("sale:deliverHead:list")
    public R list(@RequestParam Map<String, Object> params){

        PageUtils page = deliverHeadService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 销售发货单信息
     */
    @SysLog("销售发货单信息")
    @ApiOperation("销售发货单信息")
    @GetMapping("/info/{id}")
    @RequiresPermissions("sale:deliverHead:info")
    public R info(@PathVariable("id") Long id){

		DeliverHeadEntity deliverHead = deliverHeadService.getInfo(id);

        return R.ok().put("deliverHead", deliverHead);
    }

    /**
     * 销售发货单保存
     */
    @SysLog("销售发货单保存")
    @ApiOperation("销售发货单保存")
    @PostMapping("/save")
    @RequiresPermissions("sale:deliverHead:save")
    public R save(@RequestBody DeliverHeadEntity deliverHead){

		deliverHeadService.saveInfo(deliverHead);

        return R.ok();
    }

    /**
     * 销售发货单修改
     */
    @SysLog("销售发货单修改")
    @ApiOperation("销售发货单修改")
    @PostMapping("/update")
    @RequiresPermissions("sale:deliverHead:update")
    public R update(@RequestBody DeliverHeadEntity deliverHead){

		deliverHeadService.updateInfo(deliverHead);

        return R.ok();
    }

    /**
     * 销售发货单删除
     */
    @SysLog("销售发货单删除")
    @ApiOperation("销售发货单删除")
    @GetMapping("/delete/{id}")
    @RequiresPermissions("sale:deliverHead:delete")
    public R delete(@PathVariable("id") Long id){

		deliverHeadService.deleteInfo(id);

        return R.ok();
    }

    /**
     * 销售发货单审核
     */
    @SysLog("销售发货单审核")
    @ApiOperation("销售发货单审核")
    @GetMapping("/check/{id}")
    @RequiresPermissions("sale:deliverHead:check")
    public R check(@PathVariable("id") Long id){

        deliverHeadService.checkInfo(id);

        return R.ok();
    }
    /**
     * 销售发货单导出
     */
    @SysLog("销售发货单导出")
    @ApiOperation("销售发货单导出")
    @GetMapping("/export")
    @RequiresPermissions("sale:deliverHead:export")
    public void export(@RequestParam Map<String, Object> params){

        List<DeliverHeadExportVO> list = deliverHeadService.exportList(params);

        exportExcel(list,"销售发货单","销售发货单",DeliverHeadExportVO.class,"销售发货单.xls");
    }


}
